package com.digital.herbarium.Controller;

import com.digital.herbarium.annotation.CheckToken;
import com.digital.herbarium.Entity.Menu;
import com.digital.herbarium.Entity.ResponseResult;
import com.digital.herbarium.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/menu")
public class MenuController {

    @Autowired
    MenuService menuService;

    @GetMapping("getMenuInfo")
    @CheckToken()
    public ResponseResult getMenuInfo(Menu menu){
        if(menu.getCategory() != null && menu.getCategory() != 0){
            return ResponseResult.SUCCESS().setData( menuService.getMenuCategory(menu));
        }else{
            return ResponseResult.SUCCESS().setData( menuService.getMenuInfo());
        }

    }
}
